import { http } from "../../utils/http";
Page({
    data: {
        list: [],            //医院列表
        page:1
    },
    //页面加载，请求医院列表
    onLoad() {
        this.getList()
    },
    //页面触底
    onReachBottom(){
        this.data.page++            //page=3
        // console.log(this.data.page)
        this.getList()

    },

    //获取医院列表
    async getList() {
        wx.showLoading({
            title: '正在加载',
        })
        //请求列表页
        let result = await http({
            url: "87-60",
            data: {
                provinceName: "北京",
                page: this.data.page,           
            }
        })
        let newPage=result.data.showapi_res_body.hospitalList
        this.setData({
            list: this.data.list.concat(newPage)
        })
        wx.hideLoading()            //隐藏loading

    },

    //显示tabbar的dot
    handleClick() {
        //显示红色点点
        wx.showTabBarRedDot({
            index: 1,
        })

        //隐藏tabBar
        wx.hideTabBar({
            animation: true,
        })

        //设置导航栏样式
        wx.setTabBarStyle({
            color: "#fff",
            selectedColor: "#ff0000",
            backgroundColor: '#ffff00',
            borderStyle: "black"
        })

        //添加肩章
        wx.setTabBarBadge({
            index: 1,
            text: "99"
        })
    },
    //跳转详情页
    toDetail(e) {
        // console.log(e)
        let id = e.currentTarget.id;      //医院id
        //页面跳转
        wx.navigateTo({
            url: '/pages/detail/detail?id=' + id,

        })
    }



})